new Vue({
    el: '#app',
    data() {
        return {
            //修改大模型悬浮框是否可以点击
            changeMultiBtn: true,
            streaming: false,
            //流式控制器
            abortCtrl: null,
            isflageIOX: true,
            clipboard: {
                content: "",
            },
            currentStep: 1,
            subjectTitle: '',
            //通用模板列表
            generalList: [
                { id: '-1', modelName: '', coverUrl: '../../../image/loading2.gif' },
                { id: '-1', modelName: '', coverUrl: '../../../image/loading2.gif' },
                // { id: '7', modelName: '', coverUrl: '../images/ppt/ppt-common1.png' },
                // { id: '8', modelName: '', coverUrl: '../images/ppt/ppt-common2.png' },
            ],
            //通用模板分页信息
            generalPage: {
                page: 1,
                size: 2,
                total: 0,
            },
            //专业模板
            specialList: [
                { id: '-1', modelName: '', coverUrl: '../../../image/loading2.gif' },
                { id: '-1', modelName: '', coverUrl: '../../../image/loading2.gif' },
                // { id: '7', modelName: '', coverUrl: '../images/ppt/ppt-common1.png' },
                // { id: '8', modelName: '', coverUrl: '../images/ppt/ppt-common2.png' },
                // { id: '5', modelName: '', coverUrl: '../images/ppt/ppt-common1.png' },
                // { id: '6', modelName: '', coverUrl: '../images/ppt/ppt-common2.png' }
            ],
            //专业模板分页信息
            specialPage: {
                page: 1,
                size: 2,
                total: 0,
            },
            //是否加载数据中，节流处理
            generalLoading: false,
            specialLoading: false,
            //素材列表
            materialList: [
                // { id: '1', fileName: '关于XXX的工作方案.docx', type: 'word', fileSize: '120.3KB' },
                // { id: '2', fileName: '关于XXXXX的工作方案.docx', type: 'word', fileSize: '136.52KB' },
                // { id: '3', fileName: '关于XXX的工作方案.docx', type: 'word', fileSize: '120.3KB' },
                // { id: '4', fileName: '关于XXXXX的工作方案.docx', type: 'word', fileSize: '136.52KB' },
            ],
            //当前选中模板
            curModelId: '',
            extractOutline: '',
            dataUrl: '',
            //大纲内容
            outLineMdContent: '',
            outLineContent: '',
            //ppt格式方案
            pptResult: {},
            programMdContent: '',
            programHtmlContent: '',
            fileType: 0,
            disabledInp: false,
            // 设置每个分片的大小（字节）
            CHUNK_SIZE: 5 * 1024 * 1024 + "", // 1MB
            retryNum: 0,
            myindex: -1,
            fileSuffixs: ["doc", "docx"],
            count: 0,
            attachmentId: '',
            //ppt生成对象
            pptForm: {
                //标题
                title: '',
                //模板id
                curModelId: '',
            },
            wordFile: {},
            upLoadFile: false,
            fileName: '',
            fileSize: '',
            uploadFileType: 'word',
            wordSuffix: ['doc','docx','txt'],
            pptSuffix: ['pptx','ppt'],
            pdfSuffix: ['pdf'],
        }
    },
    watch: {
        streaming: {
            handler(newValue, oldValue) {
                this.changeMultiBtn = !newValue
            },
            immediate: true
        },
    },
    computed: {
        generalItems() {
            // 使用Array.prototype.reduce来将数组中的元素两两配对  
            return this.generalList.reduce((acc, item, index, array) => {
                // 检查当前索引是否是偶数，并且不是最后一个元素（避免与不存在的下一个元素配对）  
                if (index % 2 === 0 && index < array.length - 1) {
                    acc.push([array[index], array[index + 1]]);
                }
                else if (array.length % 2 !== 0 && index === array.length - 1) {  
                  acc.push([array[index]]);  
                }  
                return acc;
            }, []);
        },
        specialItems() {
            // 使用Array.prototype.reduce来将数组中的元素两两配对  
            return this.specialList.reduce((acc, item, index, array) => {
                // 检查当前索引是否是偶数，并且不是最后一个元素（避免与不存在的下一个元素配对）  
                if (index % 2 === 0 && index < array.length - 1) {
                    acc.push([array[index], array[index + 1]]);
                }
                else if (array.length % 2 !== 0 && index === array.length - 1) {  
                    acc.push([array[index]]);  
                }   
                return acc;
            }, []);
        },
    },
    created() {
        const _this = this
        let jsApiList = []
        $.getScript("../../../js/jweixin-sgccigw-1.0.0.js" /*"js/jweixin-1.0.0.js"*/, function () {
            'use strict';
            wx.ready(function () {
                wx.onHistoryBack(() => {
                    _this.home()
                    return false
                })
            });
            jsApiList = [
                'previewFile',
                'startRecordVoiceBuffer',
                'ext_AudioRecorder_Start',
                'ext_AudioRecorder_Stop',
                'onRecordBufferReceived',
                'multiWindows_subscribe',
                'stopRecord',
                'onHistoryBack',
            ];
            wx.config({
                beta: true, // 调用wx.invoke形式的接口值时，该值必须为true。
                debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                appId: corpid,
                timestamp: '1626832073',
                nonceStr: nonceStr,
                signature: signature,
                jsApiList: jsApiList
            });
        });
    },
    mounted() {
        this.compatibleInput()

        // this.upLoadFile = true
        // this.fileName = "测试二分法11测试二分法11测试二分法11测试二分法11测试二分法11测试二分法11"
        // this.currentStep = 2
        // this.pptResult = {
        //     id: 1,
        //     name: "测试二分法11",
        //     fileSize: "112KB"
        // }
        //添加左右滑监听事件
        // this.addMoveLRListener('general', this.generalPage)
        // this.addMoveLRListener('special', this.specialPage)
        this.getModelList(1)
        this.getModelList(4)
    },
    methods: {
        handleSpecialScroll(event){
            
            const container = event.target;
            console.log(container.scrollWidth - container.scrollLeft, container.clientWidth)
            if (container.scrollWidth - container.scrollLeft - container.clientWidth < 10) {
                // 已滚动到最右侧
                console.log('已滚动到最右侧');
                //节流
                if(this.specialLoading){
                    return;
                }
                // //当页数*size < total时 page + 1并加载数据
                // if(this.specialPage.current * this.specialPage.size < this.specialPage.total){
                //     this.specialPage.current = this.specialPage.current + 1
                //     //加载数据
                    console.log('当前页：' + this.specialPage.page)
                    this.loadSpecialData(container);
                // } else {
                //     mui.toast('没有更多了', {
                //         duration: 1000,
                //         type: 'div'
                //     })
                // }   
            }
        },
        handleGeneralScroll(event){
            const container = event.target;
            if (container.scrollWidth - container.scrollLeft - container.clientWidth < 10) {
                // 已滚动到最右侧
                console.log('已滚动到最右侧');
                //节流
                if(this.generalLoading){
                    return;
                }
                //当页数*size < total时 page + 1并加载数据
                // if(this.generalPage.current * this.generalPage.size < this.generalPage.total){
                //     this.generalPage.current = this.generalPage.current + 1
                    //加载数据
                    console.log('当前页：' + this.generalPage.page)
                    this.loadGeneralData(container);
                // } else {
                //     mui.toast('没有更多了', {
                //         duration: 1000,
                //         type: 'div'
                //     })
                // }   
            }
        },
        loadSpecialData(target){
            // $(".curtain").css("display", "block");
            this.specialLoading = true
            setTimeout(() => {
                let total = this.specialPage.total
                let currentTotal = this.specialList.length
                if(total - currentTotal < 1) {
                    return;
                }
                if(total - currentTotal == 1) {
                    this.specialList.push({ id: '-1', modelName: '', coverUrl: '../../../image/loading2.gif' })
                }else if(total - currentTotal > 1){
                    this.specialList.push({ id: '-1', modelName: '', coverUrl: '../../../image/loading2.gif' })
                    this.specialList.push({ id: '-1', modelName: '', coverUrl: '../../../image/loading2.gif' })
                }
                $(target).animate({ scrollLeft: target.scrollLeft + 50},20)
                this.specialPage.page += 1
                this.getModelList(4)
                // $(".curtain").css("display", "none");
                this.specialLoading = false
            }, 1000)
        },
        loadGeneralData(target){
            // $(".curtain").css("display", "block");
            this.generalLoading = true
            setTimeout(() => {
                let total = this.generalPage.total
                let currentTotal = this.generalList.length
                if(total - currentTotal < 1) {
                    return;
                }
                if(total - currentTotal == 1) {
                    this.generalList.push({ id: '-1', modelName: '', coverUrl: '../../../image/loading2.gif' })
                }else if(total - currentTotal > 1){
                    this.generalList.push({ id: '-1', modelName: '', coverUrl: '../../../image/loading2.gif' })
                    this.generalList.push({ id: '-1', modelName: '', coverUrl: '../../../image/loading2.gif' })
                }
                $(target).animate({ scrollLeft: target.scrollLeft + 50},20)
                this.generalPage.page += 1
                this.getModelList(1)
                // $(".curtain").css("display", "none");
                this.generalLoading = false
            }, 1000)
        },
        getUploadFileType(suffix) {
            console.log("文件后缀", suffix)
            if (this.wordSuffix.includes(suffix.toLocaleLowerCase())) {
              this.uploadFileType = 'word'
            }else if (this.pptSuffix.includes(suffix.toLocaleLowerCase())) {
              this.uploadFileType = 'ppt'
            }else if (this.pdfSuffix.includes(suffix.toLocaleLowerCase())) {
              this.uploadFileType = 'pdf'
            } 
        },
        preview(item) {
            myPreviewFile(item)
        },
        //选择模板
        selModel(item){
            if('-1' == item.id) {
                return
            }
            this.pptForm.curModelId = item.id;
        },
        getModelList(type) {
            const userId = sessionStorage.getItem("userId");
            let param = {
                "userId": userId,
                "modelType": "ALI", //getLargeModelType(),
                "type": type,
                "page": 1==type?this.generalPage.page:this.specialPage.page,
                "size": 1==type?this.generalPage.size:this.specialPage.size,
                "timestamp": new Date().getTime() + "",
            };
            let AuthenticationSession = sessionStorage.getItem("Authentication");
            data = JSON.stringify(param)
            let sign = sm3(data);
            $.ajax({
                url: localUrlLink + iscp_port + "/tjAiAssistant/ppt/getTemplatesPage",
                type: "post",
                // async: false, //是否同步，false表示同步请求
                dataType: "json",
                data: data,
                headers: {
                    "Content-Type": "application/json;charset=UTF-8",
                    Authentication: AuthenticationSession,
                    sign: sign
                },
                success: (res, txt, xhr) => {
                    if (res.code == 200) {
                        if(1 == type) {
                            this.generalPage.total = res.resultValue.total
                            this.generalList = this.generalList.filter(item => item.id != '-1')
                            this.generalList = this.generalList.concat(res.resultValue.list)
                        }else {
                            this.specialPage.total = res.resultValue.total
                            this.specialList = this.specialList.filter(item => item.id != '-1')
                            this.specialList = this.specialList.concat(res.resultValue.list)
                        }
                        // this.generalList = res.resultValue.general;
                        // this.specialList = res.resultValue.special;
                    } else {
                        mui.toast('请稍后再试', {
                            duration: 1000,
                            type: 'div'
                        })
                    }
                },
                error: (e) => {
                    $(".curtain").css("display", "none");
                    mui.toast('请稍后再试', {
                        duration: 1000,
                        type: 'div'
                    })
                },
            });
        },
        directPpt() {
            if('' == this.attachmentId) {
                $(".curtain").css("display", "none");
                mui.toast('请上传文档', {
                    duration: 'long',
                    type: 'div'
                })
                return false
            }
            // if('' == this.pptForm.title) {
            //     $(".curtain").css("display", "none");
            //     mui.toast('请填写文件标题', {
            //         duration: 'long',
            //         type: 'div'
            //     })
            //     return false
            // }
            if('' == this.pptForm.curModelId) {
                $(".curtain").css("display", "none");
                mui.toast('请选择主题', {
                    duration: 'long',
                    type: 'div'
                })
                return false
            }
            const userId = sessionStorage.getItem("userId");
            let param = {
                "userId": userId,
                "curModelId": this.pptForm.curModelId,
                "attachmentId": this.attachmentId,
                "outline": this.extractOutline,
                "dataUrl": this.dataUrl,
                "outlineDz": this.dataUrl,
                "subject": this.pptForm.title,
                "modelType": "ALI", //getLargeModelType(),
                "timestamp": new Date().getTime() + "",
            };
            // $(".curtain").css("display", "block");
            this.currentStep = 2
            console.log("generateContent")
            this.streaming = true
            this.abortCtrl = streamChat(localUrlLink + iscp_port + "/tjAiAssistant/ppt/generateContent", param,
            // this.abortCtrl = streamChat(localUrlLink + iscp_port + "/tjAiAssistant/ppt/directPpt", param,
                (res) => {
                    this.streaming = false
                    //成功回调
                    console.log(res)
                    $(".curtain").css("display", "none");
                    if (res.code == 200) {
                        this.pptResult = res.resultValue;
                        this.pptResult.fileSize = calcFileSize(this.pptResult.size);
                        
                        console.log("当前步骤",this.currentStep);
                    } else {
                        mui.confirm(
                            "",
                            "请上传带有标题格式的Word文件",
                            ["确定"],
                            (e) => {
                                this.preStep()
                            }
                        );
                        // mui.toast('请上传有标题的Word文件', {
                        //     duration: 1000,
                        //     type: 'div'
                        // })
                        // setTimeout(() => {
                        //     this.preStep()
                        // }, 1500);
                    }
                }, (err) => {
                    //失败回调
                    this.streaming = false
                    $(".curtain").css("display", "none");
                    mui.confirm(
                        "",
                        "请上传带有标题格式的Word文件",
                        ["确定"],
                        (e) => {
                            this.preStep()
                        }
                    );
                }), res => {
                    this.streaming = false
                    $(".curtain").css("display", "none");
                };
        },
        markdown2Html(tmd) {
            let md = tmd.replace(/\`\`\`markdown/g, '').replace(/\`\`\`/g, '').replace(/\n/g, "  \n")
            return marked.parse(md)
        },
        //上一步
        preStep(){
            if(2 == this.currentStep){
                this.outLineContent = ''

                this.curModelId = ''
                this.extractOutline = ''
                this.dataUrl = ''
                this.attachmentId = ''
                this.upLoadFile = false
                this.uploadFileType = ''
                this.wordFile = {}
                this.pptForm = {
                    title: '',
                    curModelId: '',
                }
            }
            this.currentStep = this.currentStep - 1
        },
        //下一步
        nextStep() {
            $(".curtain").css("display", "block");
            if(1 == this.currentStep) {

            }else if(2 == this.currentStep){

            }
        },
        chooseUpload(type) {
            let filePathList = this.$refs.chooseDirRef.filePathList
            if(localStorage.getItem("showBtn") == 'true' && filePathList.length >= 2 && !this.isflageIOX ){
                this.$refs.chooseDirRef.showFilepath = true
            }else {
                this.uploadFunc()
            }
        },
        chooseDirUpload(item) {
            if(item&&(item.id != 0)) {
                let _that = this
                wx.invoke("ext_FileBrowser_AppointDirChooseFile", 
                    {data : {"appointDirPath": item.pathName}}, 
                    (res) => {
                        _that.channelId = "ppt_upload_" + _that.createNonceStr(8) + new Date().getTime() + "";
                        console.log('res', res)
                        let recordArr = [{
                            name: res.name,
                            path: res.filePath,
                            fileSize: res.size
                        }]
                        const suffix = recordArr[0].name.split('.').reverse()[0]
                        if (!_that.fileSuffixs.includes(suffix.toLocaleLowerCase())) {
                            mui.toast('请上传带有标题格式的Word文件', {
                                duration: 'long',
                                type: 'div'
                            })
                            return
                        }
                        if(recordArr[0].fileSize > 50 *1024 *1024){
                            mui.toast('上传文件大小请控制在50MB内', {
                                duration: 'long',
                                type: 'div'
                            })
                            return
                        }
                        if (checkFileNameForSensitiveWords(recordArr[0].name)) {
                            mui.toast('检测到敏感内容，请确认后再试。', {
                                duration: 'long',
                                type: 'div'
                            })
                            return false
                        }
                        _that.checkList(recordArr[0].path, recordArr[0].name, _that.channelId, recordArr[0].fileSize)
                    })
            }else {
                this.uploadFunc()
            }
        },
        uploadFunc(type) {
            let _that = this
            wx.invoke("ext_FileBrowser_StartPreView", {}, function (res) {
                _that.channelId = "ppt_upload_" + _that.createNonceStr(8) + new Date().getTime() + "";

                if (_that.isflageIOX) {
                    const suffix = res.name.split('.').reverse()[0]
                    if (!_that.fileSuffixs.includes(suffix.toLocaleLowerCase())) {
                        mui.toast('请上传带有标题格式的Word文件', {
                            duration: 'long',
                            type: 'div'
                        })
                        return
                    }
                    if(res.size > 50 *1024 *1024){
                        mui.toast('上传文件大小请控制在50MB内', {
                            duration: 'long',
                            type: 'div'
                        })
                        return
                    }
                    if (checkFileNameForSensitiveWords(res.name)) {
                        mui.toast('检测到敏感内容，请确认后再试。', {
                            duration: 'long',
                            type: 'div'
                        })
                        return false
                    }
                    console.log("ios上传文件")
                    _that.checkList(res.filePath, res.name, _that.channelId, res.size)
                } else {
                    let recordArr = JSON.parse(res.result)
                    const suffix = recordArr[0].name.split('.').reverse()[0]
                    if (!_that.fileSuffixs.includes(suffix.toLocaleLowerCase())) {
                        mui.toast('请上传带有标题格式的Word文件', {
                            duration: 'long',
                            type: 'div'
                        })
                        return
                    }
                    if(recordArr[0].fileSize > 50 *1024 *1024){
                        mui.toast('上传文件大小请控制在50MB内', {
                            duration: 'long',
                            type: 'div'
                        })
                        return
                    }
                    if (checkFileNameForSensitiveWords(recordArr[0].name)) {
                        mui.toast('检测到敏感内容，请确认后再试。', {
                            duration: 'long',
                            type: 'div'
                        })
                        return false
                    }
                    _that.checkList(recordArr[0].path, recordArr[0].name, _that.channelId, recordArr[0].fileSize)
                }
            })
        },
        checkList(path, name, id, fileSize, hash, index) {
            $(".curtain").css("display", "block");
            
            let that = this
            that.disabledInp = true
            let iscp_port
            if (sessionStorage.getItem("iscp_port")) {
                iscp_port = sessionStorage.getItem("iscp_port");
            } else {
                iscp_port = ""
            }
            let Authentication = sessionStorage.getItem("Authentication");
            const timestamp = new Date().getTime() + ""
            let userId = sessionStorage.getItem("userId");
            let sign = sm3(timestamp + "&" + userId)
            that.fileName = name
            that.fileSize = that.calcFileSize(fileSize)
            wx.invoke("ext_Net_FragmentUpload", {
                data: {
                    serverAddress: localUrlLink + iscp_port + `/tjAiAssistant/storage/splitUpload2?channelId=${id}`,
                    filePath: path,
                    fragmentSize: that.CHUNK_SIZE,
                    fileName: name,
                    fileHash: hash ? hash : '',
                    upLoadFragmentIndex: index ? index : '',
                    channelId: id,
                    headerData: {
                        sign: sign,
                        userId: userId,
                        type: '',
                        timestamp: timestamp,
                        Authentication: Authentication,
                    }
                },
            }, function (res) {
                if (res.err_msg.endsWith(":ok")) { //成功结果
                    //上传完成
                    $(".curtain").css("display", "none");
                    mui.toast("上传成功", {
                        duration: "long",
                        type: "div"
                    });
                    // const suffix = name.split('.').reverse()[0]
                    // that.attachmentId = id;
                    // that.upLoadFile = true
                    // that.getUploadFileType(suffix)
                    // that.setWordFile(id,name,fileSize)
                    addPendingData(109, id)
                    that.uploadComplete(id, name, fileSize)
                } else if (res.err_msg.endsWith(":cancel")) {
                    $(".curtain").css("display", "none");
                    that.cleanData();
                    return
                } else {
                    $(".curtain").css("display", "none");
                    //上传失败
                    if (that.myindex != Number(res.upLoadFragmentIndex)) {
                        that.myindex = Number(res.upLoadFragmentIndex);
                        that.retryNum = 0;
                    }
                    setTimeout(() => {
                        if (that.retryNum > 4) {
                            // that.retryNum = 0
                            var btnArray = ["取消", "确定"];
                            var i = 0
                            mui.confirm(
                                "是否进行重试？",
                                "上传失败",
                                btnArray,
                                (e) => {
                                    if (i > 0) return
                                    i++
                                    if (e.index == 1) {
                                        that.checkList(path, name, id, fileSize, res.fileHash, res.upLoadFragmentIndex)
                                    } else {
                                        that.cleanData()
                                    }
                                }
                            );
                        } else {
                            that.retryNum++

                            that.checkList(path, name, id, fileSize, res.fileHash, res.upLoadFragmentIndex)
                        }

                    }, (that.retryNum + 1) * 1000)

                }
            })
        },
        setWordFile(id, name, fileSize) {
            this.wordFile = {
                id: id,
                fileName: name,
                type: 'WORD',
                size: fileSize,
                fileSize: calcFileSize(fileSize)
            }
            console.log(this.wordFile);
        },
        uploadComplete(id, name, fileSize) {
            const userId = sessionStorage.getItem("userId");
            let param = {
                "userId": userId,
                "channelId": id,
                "modelType": "ALI", //getLargeModelType(),
                "timestamp": new Date().getTime() + "",
            };
            let AuthenticationSession = sessionStorage.getItem("Authentication");
            data = JSON.stringify(param)
            let sign = sm3(data);
            $.ajax({
                url: localUrlLink + iscp_port + "/tjAiAssistant/ppt/extractFileOutline",
                type: "post",
                async: false, //是否同步，false表示同步请求
                dataType: "json",
                data: data,
                headers: {
                    "Content-Type": "application/json;charset=UTF-8",
                    Authentication: AuthenticationSession,
                    sign: sign
                },
                success: (res, txt, xhr) => {
                    $(".curtain").css("display", "none");
                    if (sm3(res.resultValueStr) == xhr.getResponseHeader("sign")) {
                        let Authentication = xhr.getResponseHeader("Authentication")
                        if (res.code == 200) {
                            if (Authentication) {
                                sessionStorage.setItem("Authentication", Authentication);
                            }
                            let result = res.resultValue

                            this.extractOutline = result.outline
                            this.dataUrl = result.dataUrl
                            
                            $(".curtain").css("display", "none");
                            mui.toast("上传成功", {
                                duration: "long",
                                type: "div"
                            });
                            const suffix = name.split('.').reverse()[0]
                            this.attachmentId = id;
                            this.upLoadFile = true
                            this.getUploadFileType(suffix)
                            this.setWordFile(id,name,fileSize)

                        } else {
                            // mui.toast('请稍后再试', {
                            //     duration: 1000,
                            //     type: 'div'
                            // })
                            mui.confirm(
                                "",
                                "请上传带有标题格式的Word文件",
                                ["确定"],
                                (e) => {
                                    
                                }
                            );
                        }
                    }
                },
                error: (e) => {
                    $(".curtain").css("display", "none");
                    // mui.toast('请稍后再试', {
                    //     duration: 1000,
                    //     type: 'div'
                    // })
                    mui.confirm(
                        "",
                        "请上传带有标题格式的Word文件",
                        ["确定"],
                        (e) => {
                            
                        }
                    );
                },
            });
        },
        calcFileSize(fileSize) {
            let kbf = (Math.floor((fileSize / 1024) * 100) / 100).toFixed(2);
            if (kbf > 1000) {
                //显示 MB
                return (Math.floor((fileSize / (1024 * 1024)) * 100) / 100).toFixed(2) + 'MB';
            }
            return kbf + 'KB';
        },
        cleanData() {
            this.disabledInp = false
        },
        handleScrollBottom(refName) {
            // this.$nextTick(() => {
                let scrollElem = this.$refs[refName];
                if(scrollElem) {
                    $(scrollElem).stop(true, true)
                    $(scrollElem).animate({ scrollTop: $(scrollElem).prop('scrollHeight')},20)
                }
            // })
        },
        //分享
        share(result) {
            shareIgw({
                sceneNo: '109',
                shareType: 1,
                attchId: result.id
            })
         },
        //发送邮件
        sendMail(result) { 
            mySendMail('直接生成PPT',"answerAttach=" + result.id,10,9)
        },
        syncToInner(result) { 
            mySyncToInner('直接生成PPT',"answerAttach=" + result.id,10,9)
        },
        //复制按钮
        copy() {
            let text1 = this.clipboard.content;
            var clipboard = new Clipboard(".tag-read", {
                // 通过target指定要复印的节点
                text: function () {
                    return text1;
                },
            });
            clipboard.on("success", (e) => {
                addOperator(2, 11, "复制文本", 1, 1, "复制成功");
                mui.toast("复制成功", {
                    duration: "long",
                    type: "div"
                });
            });
            clipboard.on("error", (e) => {
                addOperator(2, 11, "复制文本", 1, 0, "复制失败");
            });
        },
        // 判断安卓还是ios
        compatibleInput() {
            //获取浏览器的userAgent,并转化为小写
            var ua = navigator.userAgent.toLowerCase();
            //判断是否是苹果手机，是则是true
            var isIos = ua.indexOf("iphone") != -1 || ua.indexOf("ipad") != -1;
            if (isIos) {
                this.isflageIOX = true;
            } else {
                this.isflageIOX = false;
            }
        },
        home() {
            $(location).attr("href", "index.html");
        },
        createSgin(data) {
            let hashData = sm3(data);
            let hashData_last = sm3(hashData);
            hashData_last = hashData_last.substr(0, 5);
            hashData += hashData_last;
            let sign = hashData;
            return sign;
        },
        createNonceStr(len) {
            var e = len ? len : 16;
            var t =
              "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
              a = t.length,
              n = "";
            for (i = 0; i < e; i++)
              n += t.charAt(Math.floor(Math.random() * a));
            return n;
        },
    }
})